from microbit import *
import time
import Obloq
SSID="SSID......"
PASSWORD="pw......"
IP="192.168.3.61"
PORT="8877"

uart.init(baudrate=9600, bits=8, parity=None, stop=1, tx=pin2, rx=pin1) 
while Obloq.connectWifi(SSID,PASSWORD,10000)!=True:
  display.scroll('wait')
  
display.scroll(Obloq.ifconfig())
Obloq.httpConfig(IP,PORT)

while True:
  
  tmp=pin0.read_analog()
  display.scroll(round(tmp*330/1024,1))
  errno,resp = Obloq.get("?temperature="+str(round(tmp*330/1024,1)),10000)
  if errno ==200:
    display.scroll('ok')
  else:
    display.scroll(str(errno))
    
  if errno==999:
    display.scroll('RS')
    Obloq.connectWifi(SSID,PASSWORD,10000)
    display.scroll(Obloq.ifconfig())
    Obloq.httpConfig(IP,PORT)
  time.sleep(600) 
  